#include "Renderer_PCH.h"
#include "RFramebuffer.h"

/*--------------------------------------------------------------------------*/

RFramebuffer::RFramebuffer() :
	m_handle(0),
	m_clearFlag(0),
	m_depthstencil(NULL)
{
	for (uint i = 0; i < RFRAMEBUFFER_MAX_COLORS; ++i)
	{
		m_color[i] = NULL;	
	}
}

/*--------------------------------------------------------------------------*/

RFramebuffer::~RFramebuffer()
{
	if (m_handle != 0)
	{
		glDeleteFramebuffers(1, &m_handle);
	}
}

/*--------------------------------------------------------------------------*/

void RFramebuffer::Bind()
{
	glBindFramebuffer(GL_FRAMEBUFFER, m_handle);
}

/*--------------------------------------------------------------------------*/

void RFramebuffer::Unbind()
{
	glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

/*--------------------------------------------------------------------------*/

int RFramebuffer::GetWidth()
{
	return m_width;
}

/*--------------------------------------------------------------------------*/

int RFramebuffer::GetHeight()
{
	return m_heigth;
}

/*--------------------------------------------------------------------------*/

RTexture* RFramebuffer::GetColor( uint i )
{
	return m_color[i];
}

/*--------------------------------------------------------------------------*/

RTexture* RFramebuffer::GetDepthstencil()
{
	return m_depthstencil;
}

/*--------------------------------------------------------------------------*/